<!--
SPDX-FileCopyrightText: 2025-present Tobias Kunze
SPDX-License-Identifier: AGPL-3.0-only WITH LicenseRef-Pretalx-AGPL-3.0-Terms
-->

{% load i18n %}
{% load history_sidebar %}

<div class="log-meta submit-group">
    <div class="logentry">
        <div class="time">
            <i class="fa fa-clock-o"></i>{{ log.timestamp|date:"SHORT_DATETIME_FORMAT" }}
        </div>
        {% if log.person %}
            <div class="person">
                {% if log.is_orga_action %}
                    <i class="fa fa-check-circle fa-fw text-success" title="{% translate 'This change was performed by an event organiser.' %}"></i>
                {% else %}
                    <i class="fa fa-user fa-fw"></i>
                {% endif %}
                {% include "orga/includes/user_name.html" with user=log.person lightbox=True %}
            </div>
        {% endif %}
        {% if log.display_object %}
            <div class="log-text">
                <i class="fa fa-list-ul"></i>
                <span>{{ log.display_object|safe }}</span>
            </div>
        {% endif %}
        <div class="log-object">
            <i class="fa fa-flag"></i>
            <span>{{ log.display }}</span>
        </div>
    </div>
    {% if is_htmx_request %}
        <div class="log-meta-item ml-auto">
            <a href="{% url 'orga:event.history.detail' event=log.event.slug pk=log.pk %}" target="_blank" class="btn btn-sm btn-outline-info">
                <i class="fa fa-external-link"></i> {% translate "Permalink" %}
            </a>
        </div>
    {% endif %}
</div>

<div class="changes-container">
    {% if log.changes %}
        <h3>{% translate "Changes" %}</h3>
        <table>
            <thead>
                <tr>
                    <th>{% translate "Field" %}</th>
                    <th>{% translate "Before" %}</th>
                    <th>{% translate "After" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for field, change in log.changes.items %}
                    {% change_row field change log %}
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
</div>
